package org.dtree.ow.common;

import org.dtree.ow.models.User;
import org.nutz.mvc.annotation.*;
import org.nutz.mvc.ioc.provider.ComboIocProvider;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by dengwubo on 2017/9/19.
 */

@Modules(scanPackage = true,packages = "org.dtree.ow")
@Ok("json:full")
@Fail("http:500")
@IocBy(type = ComboIocProvider.class, args = {"*json", "config/ioc/", "*anno", "org.dtree.ow", "*tx"})
@Encoding(input = "UTF-8",output = "UTF-8")
@SetupBy(value = SetUp.class)
public class Module {

    @At("/")
    @Ok("jsp:login")
    public String home (HttpServletRequest request){
        User user = (User) request.getSession().getAttribute("user");
        if (user!=null){
            return "jsp:page.main";
        }
        return null;
    }




}
